#version 410 core

// Declare all the semantics
#define ATTR_POSITION	0
#define ATTR_NORMAL		1
#define ATTR_COLOR		2

#define VERT_POSITION	0
#define VERT_NORMAL		1
#define VERT_COLOR		2
#define VERT_INSTANCE	3

#define FRAG_COLOR		0

layout(location = VERT_NORMAL) in vec3 vNormal;

layout(location = FRAG_COLOR, index = 0) out vec4 fColor;

void main()
{
	vec3 normal = normalize(vNormal);
	vec3 ambiantColor = vec3(0.2f);
	vec3 lightDir = normalize(vec3(-1.0f));
	vec3 lightDiffuse = vec3(0.6f, 0.6f, 1.0f);
	
	float incidence = dot(normal, lightDir);
	float diffusePower = clamp(-incidence, 0.0f, 1.0f);
	
	vec3 ambiant = ambiantColor;
	vec3 diffuse = diffusePower * lightDiffuse;
	fColor = vec4(ambiant + diffuse, 1.0f);
}
